﻿using CoreShop.Library;
using CoreShop.Model;
using CoreShop.Model.FromBody;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoreShop.Services.Services.System
{
    public class HandoverBusiness
    {
        /// <summary>
        /// 充值信息
        /// </summary>
        /// <param name="DutyId"></param>
        /// <returns></returns>
        public List<ApiPosDutyRecharge> GetDutyRechargeInfoList(ClassDataDto classData)
        {
            List<ApiPosDutyRecharge> list = new List<ApiPosDutyRecharge>();
            var paymentsList = new corecmspaymentsService().GetList();
            foreach (var item in classData.userDeposits)
            {
                var findItem = paymentsList.Find(p=>p.id== item.paymentId);
                if (findItem == null) continue;
                ApiPosDutyRecharge apiPosDutyRecharges = new ApiPosDutyRecharge();
                //apiPosDutyRecharges.posDutyRechargeId = p.pos_duty_recharge_id;
                //apiPosDutyRecharges.posDutyId = p.pos_duty_id;
                apiPosDutyRecharges.balanceTypeId = findItem.id.ToString();
                if (findItem.tenantBalanceTypeId > 0)
                    apiPosDutyRecharges.balanceTypeId = findItem.tenantBalanceTypeId.ToString();
                apiPosDutyRecharges.amountBalance = item.Amount;
                apiPosDutyRecharges.rechargeNum = 1 + "";
                list.Add(apiPosDutyRecharges);
            }
            return list;
        }

        public List<ApiPosDutySale> GetDutySalseInfoList(ClassDataDto classData)
        {
            List<ApiPosDutySale> list = new List<ApiPosDutySale>();
            var paymentsList = new corecmspaymentsService().GetList();
            foreach (var item in classData.Consumption)
            {
                var findItem = paymentsList.Find(p => p.id == item.paymentId);
                if (findItem == null) continue;
                ApiPosDutySale apiPosDutysalse = new ApiPosDutySale();
                //apiPosDutysalse.posDutySaleId = p.pos_duty_sale_id;
                // apiPosDutysalse.posDutyId = p.pos_duty_id;
                apiPosDutysalse.balanceTypeId = findItem.id.ToString();
                if (findItem.tenantBalanceTypeId > 0)
                    apiPosDutysalse.balanceTypeId = findItem.tenantBalanceTypeId.ToString();
                apiPosDutysalse.amountBalance = item.Amount;
                apiPosDutysalse.saleNum = item.payCount.ToString();
                list.Add(apiPosDutysalse);
            }
            return list;
        }
    }
}
